package com.example.intelligentattendancesystem.controller;

import com.example.intelligentattendancesystem.pojo.Leave;
import com.example.intelligentattendancesystem.service.LeaveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;
import java.util.List;

/**
 * @author
 * @version 1.0
 * @className LeaveController
 * @since 1.0
 */
@RestController
@RequestMapping("smartAttendance/leave")
public class LeaveController {

    @Autowired
    LeaveService leaveService;
    /**
     * 获取请假记录
     * @param userId
     * @return
     */
    @RequestMapping("/getLeave")
    public List<Leave> getLeave(int userId){
        List<Leave> leaveService1 = leaveService.getLeaveService(userId);
        return leaveService1;
    }

    /**
     * 获取一个月中所有的请假记录
     * @return
     */
    @RequestMapping("/getAllLeaveMon")
    public List<Leave> getAllLeaveMon() throws ParseException {
        List<Leave> leaveService1 = leaveService.getAllLeaveMon();
        return leaveService1;
    }
    @RequestMapping("/getAllLeaveSev")
    public List<Leave> getAllLeaveSev() throws ParseException {
        List<Leave> leaveService1 = leaveService.getAllLeaveSev();
        return leaveService1;
    }
    @RequestMapping("/getAllLeaveAll")
    public List<Leave> getAllLeaveAll() throws ParseException {
        List<Leave> leaveService1 = leaveService.getAllLeaveAll();
        return leaveService1;
    }
    @RequestMapping("/addLeaves")
    public int addLeaves(@RequestBody List<Leave> leaves){
        int i = leaveService.addLeavesService(leaves);
//        System.out.println(leaves);
        return i;
    }

    @RequestMapping("/setLeaves")
    public int modifyLeaves(@RequestBody List<Leave> leaves){
        return leaveService.modifyLeaves(leaves);
    }
}
